/* 翻译在离职状态*/
function fzzl_employeeStatusRenderer(e) {
	var record = e.record;
	var s;
	if (record.employeeStatusId == 1) {
		s = '<input readonly="readonly" style="width: 100%;border:0;color:green;" value="在职" />';
	} else {
		s = '<input readonly="readonly" style="width: 100%;border:0;color:gray;" value="离职" />';
	}
	return s;
}

/* 根据员工前6位身份证号码获取该身份证号码对应的地址，性别，出生日期，如果在系统中存在，带出员工信息 */
function fzzl_checkIdCardAndGet(idcard) {
	//alert(base);
	if(public_isEmpty(idcard))
		return null;
	//alert(idcard);
	var ret = public_getServerData(base
			+ "/hrp/d/idcard/controller/checkIdCard/checkAndGet", {
		idcard : idcard
	});
	return ret;
}

//查看员工信息
function fzzl_editEmployeeInit(){
	var rows = employeeGrid.getSelecteds();
	if(rows.length>1){
		public_showErrorTips("只允许选择一条进行修改！");
		return ;
	}
	var data = employeeGrid.getSelected();
	if (data == undefined){
		public_showErrorTips("请选择相应的员工进行修改.");
		return ;
	}
	var customerId = data.customerId;
	if(customerId == undefined){
		customerId=0;
	}
	
	//如果人事代理类型，则在BussinessagentTab添加修改/查看页签
	if(public_isEmpty(data.customerTypeId) || data.customerTypeId == individualagent){
		var title = "全部-人事代理协议查看";
		var name = "代理--"+data.name;
		var url = base + "/hrp/m/employee/pa/controller/mPaEmployee/paEmployeeAllInfoInit?employeeCustomerId=" + data.employeeCustomerId + "&customerTypeId=" + individualagent;
		public_addMainTab(title, name, url);
	} else if (data.customerTypeId == businessagent) {

		// 如果企业代理类型，则在MainTab添加修改/查看页签
		var tabs = null;
		var tabName = ""
		if (data.customerTypeId == "") {
			tabName = "mainTabs";
			tabs = window.parent.mini.get(tabName);
		} else if (data.customerTypeId == businessagent) {
			// tabName="paTabs";
			tabName = "mainTabs";
			tabs = window.parent.parent.parent.mini.get(tabName);
		}
		// var tabs = window.parent.mini.get(tabName);
		var tab3 = {
			title : "代理--" + data.name + "查看",
			url : base + "/hrp/m/employee/pa/controller/mPaEmployee/paEmployeeAllInfoInit?employeeCustomerId="
					+ data.employeeCustomerId
					+ "&customerTypeId="
					+ businessagent,
			showCloseButton : true
		};

		tabs.addTab(tab3);
		tabs.activeTab(tab3);
	}
	else if( data.customerTypeId == dispatch ) {
		fzzl_addMainTabParent2("派遣员工查看", "派遣员工查看", base
				+ "/hrp/m/employee/controller/mEmployee/updateInit?employeeId="
				+ data.id+"&employeeCustomerId="+data.employeeCustomerId);
	}
}

/*
 * 在mainTabs内添加tab并选中
 * 
 * tabName:需要显示tab的name
 * TabTitle:需要显示tab的title
 * TabUrl:需要跳转并选中页面的url
 */
function fzzl_addMainTabParent2(tabName,TabTitle,TabUrl) {
	if(public_isEmpty(tabName) || public_isEmpty(TabTitle) || public_isEmpty(TabUrl))
		return;
	var tabs = window.parent.parent.mini.get("mainTabs");
	var tab = new Object;
	tab.name = tabName;
	tab.title = TabTitle;
	tab.showCloseButton = true;
	tab.url = TabUrl;
	tabs.addTab(tab);
	tabs.activeTab(tab);
}

// 查看申报信息相关联的材料信息
function fzzl_viewFileByApplyIds(applyIds,showDivId) {
	var ret = public_getServerData( base + "/hrp/si/welfareNeedFileInstance/controller/SiWelfareNeedFileInstance/viewFileByApplyIds",
			{
				applyIds : applyIds
			});
	if (ret != null && ret.data != null) {
//		ret = ret.replace(new RegExp(" id=\"","gm")," id=\"data");
//		ret = ret.replace(new RegExp(" name=\"","gm")," name=\"data");
		$("#" + showDivId).append(ret.data);
		mini.parse();
//		public_loadFileMsgByNeedIds(needIds);
	}
	return ret;
}